import {
	CalendarExpBarActionType,
	ICtrlEvent,
	ICalendarExpBarAbility,
	ICalendarExpBarControllerParams,
	ICalendarExpBarModel,
	ICalendarExpBarStore,
	IParam,
	ICalendarExpBarController,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getExpBarClassNames,
	handleCtrlAction,
	handleCtrlDestroy,
	handleCtrlInit,
	handleQuickSearch,
	handleToolbarItemClick,
	useCtrlAction,
	useCtrlBasic,
	useCtrlControllerParams,
	useCtrlProps,
} from '../use-ctrl';

/**
 * 日历导航输入参数
 *
 * @export
 * @return {*}
 */
export function useCalendarExpBarProps() {
	return {
		...useCtrlProps(),
		openView: Function,
		newView: Function,
	};
}

/**
 * 日历导航基础参数
 *
 * @export
 * @param {ICalendarExpBarModel} model
 * @param {IParam} props
 * @return {*}
 */
export function useCalendarExpBarBasic(
	model: ICalendarExpBarModel,
	props: IParam
) {
	const getClassNames = (props: IParam) => {
		const names = getExpBarClassNames(model, props);
		return names;
	};
	return {
		...useCtrlBasic(model, props),
		getClassNames,
		handleToolbarItemClick,
		handleQuickSearch,
		handleCtrlDestroy,
		handleCtrlInit,
		handleCtrlAction,
	};
}

/**
 * 日历导航部件行为
 *
 * @export
 */
export function useCalendarExpBarAction(
	controller: ICalendarExpBarController<
		ICalendarExpBarStore,
		ICalendarExpBarAbility
	>
) {
	return {
		...useCtrlAction(controller),
	};
}

/**
 * 日历导航部件控制器
 *
 * @export
 */
export function useCalendarExpBarControllerParams<
	S extends ICalendarExpBarStore,
	M extends ICalendarExpBarModel
>(
	model: M,
	props: any,
	evt: QXEvent<ICtrlEvent<CalendarExpBarActionType, ICalendarExpBarAbility>>,
	otherParams: IParam = {}
): ICalendarExpBarControllerParams<
	CalendarExpBarActionType,
	ICalendarExpBarAbility
> {
	return {
		...useCtrlControllerParams<S, M>(model, props, evt, otherParams),
		openView: props.openView,
		newView: props.newView,
	};
}
